#include "Test.h"

Test* Test::_instance = NULL;

Test* Test::getInstance(void) {
	if(_instance == NULL)
		_instance = new Test;
	return _instance;
}

void Test::runAllTests(void) {
	cout<<"Testing\n\n";
	
	cout<<"Player stats... ";
	this->testPlayerStats();
	cout<<"PASS\n";
	cout<<"Player class... ";
	this->testPlayerClass();
	cout<<"PASS\n";

	cout<<endl;
}

void Test::testPlayerStats(void) {
	// constructor Test
	PlayerStats statsTest;
	assert(statsTest.getHitPoints() == 1);
	assert(statsTest.getMaxHitPoints() == 1);
	assert(statsTest.getManaPoints() == 1);
	assert(statsTest.getMaxManaPoints() == 1);
	assert(statsTest.getDamage() == 1);
	assert(statsTest.getBonusDamage() == 0);

	// setStats Test 
	statsTest.setStats(20, 33, 666);
	assert(statsTest.getHitPoints() == 20);
	assert(statsTest.getMaxHitPoints() == 20);
	assert(statsTest.getManaPoints() == 33);
	assert(statsTest.getMaxManaPoints() == 33);
	assert(statsTest.getDamage() == 666);
	assert(statsTest.getBonusDamage() == 0);

	statsTest.setStats(30, 77, -56);
	assert(statsTest.getHitPoints() == 30);
	assert(statsTest.getMaxHitPoints() == 30);
	assert(statsTest.getManaPoints() == 77);
	assert(statsTest.getMaxManaPoints() == 77);
	assert(statsTest.getDamage() == 0);
	assert(statsTest.getBonusDamage() == 0);

	statsTest.setStats(-3, -6, -56);
	assert(statsTest.getHitPoints() == 0);
	assert(statsTest.getMaxHitPoints() == 0);
	assert(statsTest.getManaPoints() == 0);
	assert(statsTest.getMaxManaPoints() == 0);
	assert(statsTest.getDamage() == 0);
	assert(statsTest.getBonusDamage() == 0);

	statsTest.setStats(20, 33, 666);
	statsTest.setHitPoints(20);
	assert(statsTest.getHitPoints() == 20);
	statsTest.setHitPoints(50);
	assert(statsTest.getHitPoints() == 20);
	statsTest.setManaPoints(33);
	assert(statsTest.getManaPoints() == 33);
	statsTest.setManaPoints(38);
	assert(statsTest.getManaPoints() == 33);
	statsTest.setDamage(-43);
	assert(statsTest.getDamage() == 0);
	statsTest.setDamage(854);
	assert(statsTest.getDamage() == 854);
	statsTest.setBonusDamage(65);
	assert(statsTest.getBonusDamage() == 65);
	statsTest.setBonusDamage(-54);
	assert(statsTest.getBonusDamage() == 0);
}

void Test::testPlayerClass(void) {
	// void constructor test
	PlayerClass *classTest = new PlayerClass;
	assert(classTest->getClassString() == "DUMMY");
	//TODO Write the assert for class stats
	classTest = new PlayerClass("WARRIOR");
	assert(classTest->getClassString() == "WARRIOR");
	//TODO Write the assert for class stats
}
